﻿<UserControl
  x:Class="BookClub.Controls.BookDetails"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  x:Name="control"
  mc:Ignorable="d"
  d:DesignHeight="500" d:DesignWidth="400">

  <Grid DataContext="{Binding ElementName=control, Path=Book}">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="170" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <TextBlock Style="{StaticResource listMainText}" TextWrapping="Wrap"
      Text="{Binding Title}" />
    <TextBlock Grid.Row="1" Style="{StaticResource listText}"
      Text="{Binding Author}" />
    <TextBlock Grid.Row="2" Style="{StaticResource listDetailText}"
      Text="{Binding PublishDate, StringFormat='Published on {0:d}'}" />
    <TextBlock Grid.Row="3" Style="{StaticResource listDetailText}"
      Text="{Binding AddedDate, StringFormat='Shared on {0:d}'}" />
    <TextBlock Grid.Row="4" Style="{StaticResource listDetailText}"
      Text="{Binding Category.CategoryName, StringFormat='Category: {0}'}" />
    <TextBlock Grid.Row="5" Grid.ColumnSpan="2" Style="{StaticResource listDetailText}"
      Text="{Binding Description, Converter={StaticResource truncator}}" />

    <Border Grid.Column="1" Grid.RowSpan="5"
      HorizontalAlignment="Right" VerticalAlignment="Top">
      <Image Height="160" Source="{Binding ASIN, Converter={StaticResource bookCoverLoader}}" />
    </Border>

  </Grid>
</UserControl>
